﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


/// <summary>
/// MessageBox 用来在Page上设置一个消息弹出窗
/// </summary>
public static class MessageBox
{
    private static int msgCount;

    public static void ShowMessage(System.Web.UI.Page page, string msg)
    {
        MessageBox.msgCount++;
        string text1 = "<script language='javascript'> alert('" + msg + "');\t</script>";
        Type type = Type.GetType("System.String");
        page.ClientScript.RegisterStartupScript(type, "ShowMessage" + MessageBox.msgCount.ToString(), text1);
    }

    public static void ShowMessageAndGoHistory(System.Web.UI.Page page, string msg, int step)
    {
        MessageBox.msgCount++;
        string text1 = "<script language='javascript'> alert('" + msg + "');history.go(" + step.ToString() + ");</script>";
        Type type = Type.GetType("System.String");
        page.ClientScript.RegisterStartupScript(type, "ShowMessage" + MessageBox.msgCount.ToString(), text1);
    }

    public static void ShowMessageAndGoLocation(System.Web.UI.Page page, string msg, string location)
    {
        MessageBox.msgCount++;
        string text1 = "<script language='javascript'> alert('" + msg + "');window.location.replace('" + location + "');</script>";
        Type type = Type.GetType("System.String");
        page.ClientScript.RegisterStartupScript(type, "ShowMessage" + MessageBox.msgCount.ToString(), text1);
    }

    public static void GoBack(System.Web.UI.Page page)
    {
        MessageBox.msgCount++;
        string text1 = "<script language='javascript'> history.go(" + (-1).ToString() + ");</script>";
        Type type = Type.GetType("System.String");
        page.ClientScript.RegisterStartupScript(type, "ShowMessage" + MessageBox.msgCount.ToString(), text1);

    }

}
